package com.digitalchina.lxnsy.activity.farmTrain;

import android.content.Intent;
import android.webkit.JavascriptInterface;

import com.digitalchina.lxnsy.base.BaseHtmlActivity;
import com.digitalchina.lxnsy.toolkit.GotoUtil;

/**
 * ================================================
 * 项目名称：android
 * 类描述：成功案例
 * 创建人：rxx
 * 创建时间：2020/1/15 17:26
 * 修改备注：
 * ================================================
 */
public class TrainMyCaseActivity extends BaseHtmlActivity {

    public static final int REQUEST_CODE = 100;
    private String json = "";

    @Override
    protected void loadHtml() {
        webView.addJavascriptObject(new JsApi(), null);
        loadUrl("train-my-case");
        setTitle("成功案例");
        setRightText("新增案例");
    }

    @Override
    public void rightOnClick() {
        callJsMethod("addCase");
        GotoUtil.gotoForResultActivity(activity, TrainAddCaseActivity.class, REQUEST_CODE);
    }

    public class JsApi {

        //修改
        @JavascriptInterface
        public void goEdit(Object msg) {
            GotoUtil.gotoForResultActivity(activity, TrainAddCaseActivity.class,REQUEST_CODE,"msg", msg.toString() );
        }

        //详情
        @JavascriptInterface
        public void details(Object msg) {
            go(TrainMyCaseDetailsActivity.class);
        }



    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            callJsMethod("refresh");
        }
    }
}
